home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / usr_-_Usr_Files / BIN / APROPOS < prev    next >
Text File  |  1999-09-17  |  2KB  |  101 lines

  1. #!/bin/sh
  2. #
  3. # apropos -- search the whatis database for keywords.
  4. #
  5. # Copyright (c) 1990, 1991, John W. Eaton.
  6. #
  7. # You may distribute under the terms of the GNU General Public
  8. # License as specified in the README file that comes with the man
  9. # distribution.  
  10. #
  11. # John W. Eaton
  12. # jwe@che.utexas.edu
  13. # Department of Chemical Engineering
  14. # The University of Texas at Austin
  15. # Austin, Texas  78712
  16. #
  17. # apropos-1.4d aeb 950220
  18. #
  19.  
  20. OLDPATH=$PATH
  21. PATH=/usr/local/bin:/bin:/usr/ucb:/usr/bin
  22.  
  23. if [ $# = 0 ]
  24. then
  25.     echo "usage: `basename $0` keyword ..."
  26.     exit 1
  27. fi
  28.  
  29. manpath=`(PATH=$OLDPATH; /usr/bin/man --path) | tr : '\040'`
  30.  
  31. if [ "$manpath" = "" ]
  32. then
  33.     echo "apropos: manpath is null"
  34.     exit 1
  35. fi
  36.  
  37. if [ "$PAGER" = "" ]
  38. then
  39.     PAGER="/usr/bin/less -is"
  40. fi
  41.  
  42. # avoid using a pager if only output is "nothing appropriate"
  43. nothing=
  44. found=0
  45. while [ $found = 0 -a -n "$1" ]
  46. do
  47.     for d in $manpath /usr/lib
  48.     do
  49.         if [ -f $d/whatis ]
  50.         then
  51.             if grep -iq "$1" $d/whatis > /dev/null
  52.             then
  53.                 found=1
  54.             fi
  55.         fi
  56.     done
  57.     if [ $found = 0 ]
  58.     then
  59.     nothing="$nothing $1"
  60.     shift
  61.     fi
  62. done
  63.  
  64. if [ $found = 0 ]
  65. then
  66.     for i in $nothing
  67.     do
  68.     echo "$i: nothing appropriate"
  69.     done
  70.     exit
  71. fi
  72.  
  73. while [ $1 ]
  74. do
  75.     for i in $nothing
  76.     do
  77.     echo "$i: nothing appropriate"
  78.     done
  79.     nothing=
  80.     found=0
  81.     for d in $manpath /usr/lib
  82.     do
  83.         if [ -f $d/whatis ]
  84.         then
  85.             if grep -i "$1" $d/whatis
  86.             then
  87.                 found=1
  88.             fi
  89.         fi
  90.     done
  91.  
  92.     if [ $found = 0 ]
  93.     then
  94.         echo "$1: nothing appropriate"
  95.     fi
  96.  
  97.     shift
  98. done | $PAGER
  99.  
  100. exit
  101.